/* 
 * File:   CampaignList.h
 * Author: agu
 *
 * Created on 16 de junio de 2014, 18:21
 */

#ifndef CAMPAIGNLIST_H
#define	CAMPAIGNLIST_H
#include <gtkmm-3.0/gtkmm.h>
#include <vector>
#include <string>
#include "client_socket.h"
#include "client_WatingRoom.h"
using std::vector;
using std::string;

class CampaignList : public Gtk::Window {
public:
    CampaignList();
    void setWindowsBack(Gtk::Window *windowBack);
    void run();
    void setSocket(Client_socket s);
    ~CampaignList();
private:
    //Signal handlers:
    void loadWidgets();
    void connectWidgets();
    void close();
    void back();
    void refresh();
    void addColumns();
    void createModel();
    void select(const Gtk::TreeModel::Path& path,
            Gtk::TreeViewColumn* /* column */);
    void send(const string msj);
    string recv();
    void getGamesInfo();
    void loadGamesInfo(Gtk::TreeModel::Row row);
    vector<string> getElementos(const string& linea, char separador);
    string agregarLargo(string buffer);

    class ModelColumns : public Gtk::TreeModel::ColumnRecord {
    public:

        ModelColumns() {
            add(m_col_id);
            add(m_col_name);
            add(m_col_tot_play);
            add(m_col_join_play);
            add(m_col_status);
        }

        Gtk::TreeModelColumn<unsigned int> m_col_id;
        Gtk::TreeModelColumn<Glib::ustring> m_col_name;
        Gtk::TreeModelColumn<Glib::ustring> m_col_tot_play;
        Gtk::TreeModelColumn<Glib::ustring> m_col_join_play;
        Gtk::TreeModelColumn<Glib::ustring> m_col_status;

    };
    ModelColumns columns;
    Gtk::TreeView treeView;
    Glib::RefPtr<Gtk::ListStore> refTreeModel; //Child widgets:
    Gtk::Box vBox;
    Gtk::Window *windowsBack;
    Gtk::ScrolledWindow scrolledWindow;
    Gtk::ButtonBox buttonBox1, buttonBox2;
    Gtk::Button buttonBack, buttonRefresh;
    Gtk::Label label;
    Gtk::Entry entryName;
    WatingRoom watingRoom;
    Client_socket socket;
    vector<vector<string>>gamesInfo;
    int gameSelect;
};

#endif	/* CAMPAIGNLIST_H */

